<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.ort">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script th:src="@{/layui/layui.js}" type="text/javascript"></script>
    <link th:href="@{/layui/css/layui.css}" rel="stylesheet" />
</head>
<body>
<div class="layui-panel" style="padding: 8px;">
    <fieldset class="layui-elem-field layui-border-blue" style="padding-top: 8px;">
        <legend class="layui-form-label" style="width: 100px">优惠卷添加</legend>
        <form  class="layui-form layui-form-pane" style="margin: 20px;padding-top: 20px;">
            <div  class="layui-form-item">
                <label  class="layui-form-label">优惠卷名称</label>
                <input type="hidden" name="id" th:value="${coupons.id}">
                <div class="layui-input-block">
                    <input type="text" th:value="${coupons.name}" name="name" lay-verify="required" autocomplete="off"  placeholder="商品名称" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">优惠卷介绍</label>
                <div class="layui-input-block">
                    <input type="text" name="introduce" th:value="${coupons.introduce}"  autocomplete="off" placeholder="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">标签</label>
                <div class="layui-input-block">
                    <input type="text" name="label" th:value="${coupons.label}" autocomplete="off" placeholder="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">最低消费</label>
                <div class="layui-input-inline">
                    <input type="text" name="minimum" th:value="${coupons.minimum}" lay-verify="required|number" autocomplete="off" placeholder="单位元" class="layui-input">

                </div>
                <div class="layui-input-inline ">
                    <input style="width: 50px;margin-left: -10px"  class="layui-input layui-bg-blue" type="button" value="元">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">满减金额</label>
                <div class="layui-input-inline ">
                    <input type="text" name="reduction" th:value="${coupons.reduction}" lay-verify="required|number" autocomplete="off" placeholder="满减金额/元" class="layui-input">

                </div>
                <div class="layui-input-inline " >
                    <input style="width: 50px;margin-left: -10px"  class="layui-input layui-bg-blue" type="button" value="元">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">每人限领</label>
                <div class="layui-input-inline">
                    <input type="text" name="eachLimitGet" th:value="${coupons.eachLimitGet}" lay-verify="required|number" autocomplete="off" placeholder="限领/张" class="layui-input">

                </div>
                <div class="layui-input-inline " >
                    <input style="width: 50px;margin-left: -10px" class="layui-input layui-bg-blue" type="button" value="张">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">发布类型</label>
                <div class="layui-input-inline">
                    <input type="text" readonly="readonly" name="type" value="通用"  class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">优惠卷数量</label>
                <div class="layui-input-inline">
                    <input type="text" name="number" th:value="${coupons.number}" lay-verify="required|number"  autocomplete="off" placeholder="优惠卷数量/张" class="layui-input">
                </div>
                <div class="layui-input-inline " >
                    <input style="width: 50px;margin-left: -10px" class="layui-input layui-bg-blue" type="button" value="张">
                </div>
            </div>
            <div style="display: none">
                <a id="submitBtn" lay-submit="" lay-filter="submitBtn">提交</a>
            </div>
        </form>
    </fieldset>
</div>
<script>
    var $;
      layui.use(['form','jquery','layer'],function (){
          $ = layui.jquery;
        var form = layui.form,layer=layui.layer;

          form.on('submit(submitBtn)',function (data){

            var dataForm = data.field;
              $.ajax({
                  type:'post',
                  data:dataForm,
                  url:'/coupons/cs/save',
                  dataType:'json',
                  success:function (res){
                     var str = res.msg;
                      top.layer.msg(str)
                      let index = parent.layer.getFrameIndex(window.name);
                      parent.layer.close(index);//关闭父页面窗口
                      parent.layui.table.reload('couponsTable');
                  }
              })
          })

      })

    function clickSubmit(){
          alert("table")
          $('#submitBtn').click();
    }
</script>
</body>
</html>